﻿CREATE proc sp_themdoituong
@TenKH nvarchar(200),
@DiaChi nvarchar(200),
@SDT char(15),
@FAX char(20),
@MST char(20),
@TenNH char(200),
@SoTK char(20),
@TenTK nvarchar(200)
as
declare @dem as int
select @dem=count(*) from danhmuc_doituong where TenKH=@TenKH
if(@dem>0)
	begin
	select ErrCode=0
	end
else
	begin
	insert into danhmuc_doituong(TenKH,DiaChi,SDT,FAX,MST,TenNH,SoTK,TenTK)
	values (@TenKH,@DiaChi,@SDT,@FAX,@MST,@TenNH,@SoTK,@TenTK)
	select ErrCode=1
	end